home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_lib.arc / PCWAIT.C < prev    next >
Text File  |  1990-08-09  |  2KB  |  54 lines

  1. /**
  2. *
  3. *  Name         pcwait -- Return the value of the exit code
  4. *
  5. *  Synopsis     excode = pcwait(pretype);
  6. *               int excode        Returned exit code
  7. *               int *pretype      The manner of exit from the invoked
  8. *                                 process.
  9. *
  10. *  Description  This function returns the exit code which is set by
  11. *               the procedure PCEXIT in a invoked process (one called
  12. *               using PCEXEC or PCDOSCMD).  The manner in which the
  13. *               the child process terminated is returned as well.  The
  14. *               exit code is returned only once; subsequent calls to
  15. *               PCWAIT return zero values.
  16. *
  17. *  Returns      excode            The value of the exit code, a number
  18. *                                 between 0 and 255 set by PCEXIT.
  19. *               pretype           Pointer to a integer in which the manner
  20. *                                 of exit is returned.  The values are:
  21. *                                 0 - Normal Termination
  22. *                                 1 - Ctrl/Break
  23. *                                 2 - Critical Device Error
  24. *                                 3 - Terminated using DOS function 31 (hex)
  25. *                                     (terminate but stay resident).
  26. *
  27. *  Version      1.1  (C)Copyright Blaise Computing Inc.  1983, 1984
  28. *
  29. **/
  30. #define uthibyte(a)     (((a)>>8)&0x00ff)        /* High byte of a     */
  31. #define utlobyte(a)     ((a)&0x00ff)             /* Low byte of a      */
  32. #define utbyword(a,b)   (((a)<<8)|((b)&0x00ff))  /* a is high, b low   */
  33.  
  34. struct dreg
  35. {
  36.   unsigned ax,bx,cx,dx,si,di,ds,es;
  37. };
  38. #define DOSREG  struct dreg
  39.  
  40. int pcwait(pretype)
  41. int *pretype;
  42. {
  43.  
  44.     DOSREG dos_reg;
  45.  
  46.     utinit(&dos_reg);
  47.     dos_reg.ax = utbyword(0x4d,0);     /* Function call hex 4D         */
  48.     dos(&dos_reg);
  49.     *pretype = uthibyte(dos_reg.ax);
  50.  
  51.     return(utlobyte(dos_reg.ax));
  52.  
  53. }
  54.